Page({
  data: {
    reportKey: '',
    webViewUrl: '',
    nickName: '',
    gradeName: ''
  },

  onLoad (options) {
    if (options.reportKey) {
      const webViewUrl = `https://qiniu.jingzhuzhixing.cn/xiaochengxu/ReportHTML/report_v4.html?reportKey=${options.reportKey}`;
      const nickName = decodeURIComponent(options.nickName || '');
      const gradeName = decodeURIComponent(options.gradeName || '');

      console.log('接收到的昵称:', nickName);
      console.log('接收到的年级:', gradeName);

      this.setData({
        reportKey: options.reportKey,
        webViewUrl: webViewUrl,
        nickName: nickName,
        gradeName: gradeName
      });
    }
  },

  onShareAppMessage() {
    return {
      title: `${this.data.gradeName}${this.data.nickName}的评测报告`,
      path: `/pages/evaluation/report-view/report-view?reportKey=${this.data.reportKey}&nickName=${encodeURIComponent(this.data.nickName)}&gradeName=${encodeURIComponent(this.data.gradeName)}`,
      imageUrl: 'https://qiniu.jingzhuzhixing.cn/xiaochengxu/shareImage.png'
    }
  }
}) 